home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Chip 2007 January, February, March & April
/
Chip-Cover-CD-2007-02.iso
/
Pakiet bezpieczenstwa
/
mini Pentoo LiveCD 2006.1
/
mpentoo-2006.1.iso
/
livecd.squashfs
/
etc
/
init.d
/
autoconfig
< prev
next >
Wrap
Text File
|
2006-02-01
|
7KB
|
303 lines
#!/sbin/runscript
# Copyright 1999-2005 Gentoo Foundation
# Distributed under the terms of the GNU General Public License v2
# $Header: /var/cvsroot/gentoo/src/livecd-tools/autoconfig,v 1.42 2005/08/30 17:52:45 wolf31o2 Exp $
DHCP="yes"
DETECT="yes"
GPM="yes"
PCMCIA="no"
HOTPLUG="yes"
APM="no"
ACPI="yes"
IDEDMA="yes"
ALSA="yes"
X11="yes"
get_config() {
CMDLINE="$(cat /proc/cmdline)"
for x in ${CMDLINE} ; do
if [ "${x}" = "nodetect" ]
then
DETECT="no"
GPM="no"
HOTPLUG="no"
APM="no"
ACPI="no"
ALSA="no"
X11="no"
fi
if [ "${x}" = "nodhcp" ]
then
DHCP="no"
fi
if [ "${x}" = "nogpm" ]
then
GPM="no"
fi
if [ "${x}" = "dopcmcia" ]
then
PCMCIA="yes"
fi
if [ "${x}" = "doapm" ]
then
APM="yes"
ACPI="no"
fi
if [ "${x}" = "acpi=on" -o "${x}" = "acpi=force" ]
then
APM="no"
ACPI="yes"
fi
if [ "${x}" = "ide=nodma" ]
then
IDEDMA="no"
fi
if [ "${x}" = "nohotplug" ]
then
HOTPLUG="no"
fi
if [ "${x}" = "nosound" ]
then
ALSA="no"
fi
if [ "${x}" = "nox" ]
then
X11="no"
fi
done
}
depend() {
need modules
before net
# provide gpm pcmcia apmd acpid coldplug hdparm alsasound x-setup
}
# Checks whether a service will be started by autoconfig.
# Usage: check_svc var service [service_alternative]
check_svc() {
if [ "$1" = "yes" ]; then
if [ -x "/etc/init.d/$2" ]; then
echo "$2"
elif [ -n "$3" -a -x "/etc/init.d/$3" ]; then
echo "$3"
fi
fi
}
# Prints an ordered list of services that will be started by autoconfig.
list_services() {
get_config
local svcs="$(check_svc ${APM} apmd)"
svcs="${svcs} $(check_svc ${ACPI} acpid)"
svcs="${svcs} $(check_svc ${IDEDMA} hdparm)"
svcs="${svcs} $(check_svc ${PCMCIA} pcmcia)"
svcs="${svcs} $(check_svc ${GPM} gpm)"
svcs="${svcs} $(check_svc ${HOTPLUG} coldplug hotplug)"
svcs="${svcs} $(check_svc ${ALSA} alsasound)"
echo ${svcs}
}
start() {
echo "0" > /proc/sys/kernel/printk
get_config
if [ "${DETECT}" = "yes" ]
then
ebegin ${WARN}"Hardware detection started"
PC=$(awk -F: '/^processor/{printf "Processor"$2" is"};/^model name/{printf $2};/^vendor_id/{printf vendor};/^cpu MHz/{printf " %dMHz",int($2)};/^cache size/{printf ","$2" Cache"};/^$/{print ""}' /proc/cpuinfo 2>/dev/null)
ebegin ${GOOD}"${PC}"
eend
[ -x /usr/sbin/hwsetup ] && hwsetup -p >/dev/null
eend
else
ebegin ${WARN}"Hardware detection disabled via cmdline$NORMAL"
fi
if [ "${APM}" = "yes" ]
then
modprobe apm power_off=1 >/dev/null 2>&1 && ebegin ${GOOD}"APM BIOS found, power management functions enabled.${NORMAL}"
[ -x /etc/init.d/apmd ] && start_service apmd
else
ebegin ${GOOD}"Not Loading APM Bios support.${NORMAL}"
eend
fi
if [ "${ACPI}" = "yes" ]
then
modprobe processor >/dev/null 2>&1 && ebegin ${GOOD} ACPI power management functions enabled.${NORMAL} && modprobe thermal >/dev/null
modprobe fan >/dev/null 2>&1
modprobe button >/dev/null 2>&1
modprobe battery >/dev/null 2>&1
modprobe ac >/dev/null 2>&1
[ -x /etc/init.d/acpid ] && start_service acpid
eend
fi
if [ "${IDEDMA}" = "yes" ]
then
[ -x /etc/init.d/hdparm ] && start_service hdparm
fi
if [ "${PCMCIA}" = "yes" ]
then
ebegin ${HILITE} "PCMCIA enabled via cmdline"
[ -x /etc/init.d/pcmcia ] && start_service pcmcia
fi
if [ "${DHCP}" = "no" ]
then
sed -i -e '/^ifconfig_eth.*dhcp.*/ s/^/#/' \
-e '/^iface_eth.*dhcp.*/ s/^/#/' \
-e '/^config_eth.*dhcp.*/ s/^/#/' \
/etc/conf.d/net
ebegin ${BAD}"Skipping DHCP broadcast detection as requested on boot commandline."
fi
#Read in what hwsetup has found
[ -f /etc/sysconfig/knoppix ] && . /etc/sysconfig/knoppix
[ -f /etc/sysconfig/gentoo ] && . /etc/sysconfig/gentoo
# Mouse
if [ -n "${MOUSE_DEVICE}" ]
then
ebegin ${GOOD}"Mouse is ${HILITE}${MOUSE_FULLNAME}${GOOD} at ${HILITE}${MOUSE_DEVICE}${NORMAL}"
source /etc/sysconfig/mouse
if [ -x /usr/sbin/gpm ]
then
if [ $(grep "#MOUSE=${MOUSETYPE}" /etc/conf.d/gpm) ]
then
sed -i "\@MOUSE=${MOUSETYPE}@s@^#@@" /etc/conf.d/gpm
else
echo "MOUSE=${MOUSETYPE}" >>/etc/conf.d/gpm
fi
if [ $(grep "#MOUSEDEV=${DEVICE}" /etc/conf.d/gpm) ]
then
sed -i "\@MOUSEDEV=${DEVICE}@s@^#@@" /etc/conf.d/gpm
else
echo "MOUSEDEV=${DEVICE}" >>/etc/conf.d/gpm
fi
if [ "${GPM}" = "yes" ]
then
[ -x /etc/init.d/gpm ] && start_service gpm
fi
fi
eend
fi
if [ "${HOTPLUG}" = "yes" ]
then
#Check whether we should be using hotplug or coldplug
if [ -x /etc/init.d/coldplug ]
then
start_service coldplug
elif [ -x /etc/init.d/hotplug ]
then
start_service hotplug
fi
else
ebegin ${BAD}"Hotplug disabled via cmdline${NORMAL}"
fi
if [ "${DETECT}" = "no" ]
then
DHCP="no"
fi
if [ "${DETECT}" = "yes" ]
then
NETDEVICES="$(awk -F: '/eth.:|tr.:|ath.:|wlan.:/{print $1}' /proc/net/dev 2>/dev/null)"
fi
if [ -n "${NETDEVICES}" ]
then
for nics in ${NETDEVICES}
do
if [ "${DHCP}" = "yes" ]
then
ebegin ${GOOD}"Network device${HILITE}${nics}${GOOD} detected,${WARN} DHCP broadcasting for IP.${NORMAL}"
dhcpcd -n -h $(hostname) &
fi
eend
done
else
ebegin ${BAD}"No Network device auto detected.${NORMAL}"
fi
if [ "${DETECT}" = "yes" ]
then
[ -x /etc/init.d/mkxf86config ] && start_service mkxf86config
fi
if [ "${ALSA}" = "yes" ]
then
if [ -n "${SOUND_FULLNAME}" -o -n "${SOUND_DRIVER}" ]
then
ebegin ${GOOD}"Soundcard:"
eend
[ -n "${SOUND_FULLNAME}" ]
ebegin " ${WARN}${SOUND_FULLNAME}"
[ -n "${SOUND_DRIVER}" ]
ebegin ${WARN}" driver = ${SOUND_DRIVER}"${HILITE}
if [ -x /etc/init.d/alsasound ]
then
start_service alsasound
else
ebegin ${WARN}"/etc/init.d/alsasound not found, skipping."
einfo "You will need to set volume controls manually."
fi
for i in $(cat /proc/asound/cards | cut -d" " -f1)
do
if [ -d /proc/asound/card$i ] && [ -x /usr/bin/amixer ]
then
amixer -c $i scontrols > /etc/amixer
if [ -n "$(grep Master /etc/amixer)" ]
then
amixer -c $i -q set Master 33% unmute >/dev/null 2>&1
fi
if [ -n "$(grep PCM /etc/amixer)" ]
then
amixer -c $i -q set PCM 33% unmute >/dev/null 2>&1
fi
if [ -n "$(grep Mic /etc/amixer)" ]
then
amixer -c $i -q set Mic 33% mute cap >/dev/null 2>&1
fi
if [ -n "$(grep Wave /etc/amixer)" ]
then
amixer -c $i -q set Wave 33% unmute >/dev/null 2>&1
fi
if [ -n "$(grep Capture /etc/amixer)" ]
then
amixer -c $i -q set Capture 33% unmute cap >/dev/null 2>&1
fi
fi
done
fi
else
ebegin ${BAD}"Skipping ALSA detection as requested on boot commandline."
fi
if [ "${X11}" = "no" ]
then
touch /etc/init.d/.noxdm
fi
killall hwsetup 2>/dev/null
echo "6" > /proc/sys/kernel/printk
}
# vim: ts=4